﻿package mortal.game.view.market.sale
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import flash.events.*;
    import mortal.common.display.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;

    public class MktBagItemRenderer extends GCellRenderer
    {
        private var _item:BaseItem;

        public function MktBagItemRenderer()
        {
            var _loc_1:* = GlobalClass.getBitmap(BitmapDataConst.AlphaBMD);
            var _loc_2:* = ResourceConst.getScaleBitmap(ImagesConst.selectedBg);
            this.setStyle("downSkin", _loc_2);
            this.setStyle("overSkin", _loc_2);
            this.setStyle("upSkin", _loc_1);
            this.setStyle("selectedDownSkin", _loc_2);
            this.setStyle("selectedOverSkin", _loc_2);
            this.setStyle("selectedUpSkin", _loc_2);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._item = UIFactory.getUICompoment(BaseItem, 2, 2, this);
            this._item.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            this.configEventListener(MouseEvent.CLICK, this.clickHandler, false, 9999);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._item.dispose(param1);
            this._item = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function get data() : Object
        {
            return super.data;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            if (param1 == null)
            {
                this._item.itemData = null;
                return;
            }
            if (param1 is ItemData)
            {
                this._item.itemData = param1 as ItemData;
            }
            else if (param1 is ItemInfo)
            {
                this._item.itemCode = param1.code;
            }
            else
            {
                this._item.itemData = null;
            }
            return;
        }// end function

        public function clickHandler(event:MouseEvent) : void
        {
            if (this._item.itemData == null)
            {
                event.stopImmediatePropagation();
            }
            return;
        }// end function

    }
}
